home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / sys / dnlc.h < prev    next >
Text File  |  1995-02-14  |  3KB  |  111 lines

  1. /* @(#)dnlc.h    1.1 87/08/26 3.2/4.3NFSSRC */
  2. /*    @(#)dnlc.h 1.1 86/09/25 SMI    */
  3.  
  4. /*
  5.  * Copyright (c) 1984 Sun Microsystems Inc.
  6.  */
  7. #import <sys/pathname.h>
  8.  
  9. /*
  10.  * This structure describes the elements in the cache of recent
  11.  * names looked up.
  12.  */
  13.  
  14. #if NeXT
  15. #define    NC_NAMLEN    32    /* maximum name segment length we bother with*/
  16. #else
  17. #define    NC_NAMLEN    15    /* maximum name segment length we bother with*/
  18. #endif
  19.  
  20. struct    ncache {
  21.     struct    ncache    *hash_next, *hash_prev;    /* hash chain, MUST BE FIRST */
  22.     struct     ncache    *lru_next, *lru_prev;    /* LRU chain */
  23.     struct    vnode    *vp;            /* vnode the name refers to */
  24.     struct    vnode    *dp;            /* vno of parent of name */
  25.     char        namlen;            /* length of name */
  26.     char        name[NC_NAMLEN];    /* segment name */
  27.     struct    ucred    *cred;            /* credentials */
  28. #if    NeXT
  29.     char        *symLink;        /* contents if a symbolic link */
  30.     char        symLinkValid;        /* TRUE if symLinkValue is valid */
  31.     short        symLinkLength;        /* length (excluding null) */
  32. #endif    NeXT
  33. };
  34.  
  35. #define    ANYCRED    ((struct ucred *) -1)
  36. #define    NOCRED    ((struct ucred *) 0)
  37.  
  38. #define    NC_HASH_SIZE        64    /* size of hash table */
  39.  
  40. #define    NC_HASH(namep, namlen, vp)    \
  41.     ((namep[0] + namep[namlen-1] + namlen + (int) vp) & (NC_HASH_SIZE-1))
  42.  
  43. /*
  44.  * Macros to insert, remove cache entries from hash lists.
  45.  */
  46. #define    INS_HASH(ncp,nch)    insque(ncp, nch)
  47. #define    RM_HASH(ncp)        remque(ncp)
  48.  
  49. #define    NULL_HASH(ncp)        (ncp)->hash_next = (ncp)->hash_prev = (ncp)
  50.  
  51. /*
  52.  * Stats on usefulness of name cache.
  53.  */
  54. struct    ncstats {
  55.     int    hits;        /* hits that we can really use */
  56.     int    misses;        /* cache misses */
  57.     int    enters;        /* number of enters done */
  58.     int    dbl_enters;    /* number of enters tried when already cached */
  59.     int    long_enter;    /* long names tried to enter */
  60.     int    long_look;    /* long names tried to look up */
  61.     int    lru_empty;    /* LRU list empty */
  62.     int    purges;        /* number of purges of cache */
  63. #if    NeXT
  64.     int    valid_entries;    /* current number of valid entries */
  65. #endif    NeXT
  66. };
  67.  
  68. /*
  69.  * Hash list of name cache entries for fast lookup.
  70.  */
  71. struct    nc_hash    {
  72.     struct    ncache    *hash_next, *hash_prev;
  73. };
  74.  
  75. /*
  76.  * LRU list of cache entries for aging.
  77.  */
  78. struct    nc_lru    {
  79.     struct    ncache    *hash_next, *hash_prev;    /* hash chain, unused */
  80.     struct     ncache    *lru_next, *lru_prev;    /* LRU chain */
  81. };
  82.  
  83.  
  84. /*
  85.  *  Globals
  86.  *
  87.  *  ncsize is configuration dependent, and is set in conf/param.c
  88.  *  ncstats is used in ufs_inode.c to determine when to steal inodes from the cache
  89.  */
  90. extern int    ncsize;            /* static size of the cache */
  91. extern struct    ncache *ncache;        /* storage for all the cache entries */
  92. extern struct    ncstats ncstats;    /* cache effectiveness statistics */
  93. extern struct    nc_hash nc_hash[NC_HASH_SIZE];    /* headers for hash chains */
  94. extern struct    nc_lru nc_lru;            /* header for lru chain */
  95.  
  96. /*
  97.  *  Functions
  98.  */
  99. #if    STATIC_ONLY
  100. struct ncache *dnlc_search();
  101. #endif    STATIC_ONLY
  102. #if    NeXT
  103. struct ncache *dnlc_lookupSymLink(char *linkName, struct vnode *dvp);
  104. void dnlc_enterSymLink(char *linkName, struct vnode *dvp, struct pathname *pnp);
  105. #endif    NeXT
  106.  
  107.  
  108.  
  109.  
  110.  
  111.